import { createStore } from "vuex";

const state = {
  menusData: null, //菜单权限数据
  firstUrl: "", //获取菜单权限的第一个路由路径
  primaryRouteList: [], //一级路由

  keepAliveList: [], //需要缓存的一级路由
  childKeepAliveList: [], //需要缓存的二级路由
  scrollList: [], //记录二级路由滚动距离数组,当二级路由开启缓存时触发
};

const mutations = {
  setStateData: (state, data) => {
    if (!data.key) {
      return;
    }
    state[data.key] = data.val || "";
  },
};

export default createStore({
  state,
  mutations,
});
